package background;

/**
 * @author lizhichuan
 * @date 2024/5/23 19:09
 */
public class MultiThreadsErrorTest implements Runnable{

    static MultiThreadsError instance = new MultiThreadsError();
    int index = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(instance);
        Thread thread2 = new Thread(instance);
        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println("表面上结果是" + instance.index);
    }

    @Override
    public void run() {
         for (int i = 0; i < 10000;i++){
              index++;
         }
    }
}
